package com.ssy.lingxi.platform.template.service.controller.web;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.vo.PageVO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.template.service.entity.door.MemberProcess;
import com.ssy.lingxi.platform.template.service.model.dto.common.CollectDTO;
import com.ssy.lingxi.platform.template.service.model.dto.common.IdDTO;
import com.ssy.lingxi.platform.template.service.model.dto.common.IdListDTO;
import com.ssy.lingxi.platform.template.service.model.dto.web.SaveProcessDTO;
import com.ssy.lingxi.platform.template.service.model.qo.MemberProcessQO;
import com.ssy.lingxi.platform.template.service.model.vo.web.MemberProcessListVO;
import com.ssy.lingxi.platform.template.service.model.vo.web.MemberProcessMainVO;
import com.ssy.lingxi.platform.template.service.service.web.MemberProcessWebService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu web - 会员加工门户
 * @author fhj
 * @version 2.0.0
 * @date 2021/04/14
 */
@Api(tags = "web - 会员加工门户")
@RestController
@RequestMapping("/template/web/memberProcessWeb")
public class MemberProcessWebController extends BaseController {

    @Resource
    private MemberProcessWebService memberProcessWebService;

    @ApiOperation(value = "保存当前登录会员的加工门户")
    @PostMapping("/saveCurrMemberProcess")
    public Wrapper<Void> saveCurrMemberProcess(@RequestBody @Valid SaveProcessDTO dto) {
        return memberProcessWebService.saveCurrMemberProcess(dto, getSysUser());
    }

    @ApiOperation(value = "获取当前登录会员的加工门户")
    @GetMapping("/findCurrMemberProcess")
    public Wrapper<MemberProcess> findCurrMemberProcess() {
        return memberProcessWebService.findCurrMemberProcess(getSysUser());
    }

    @ApiOperation(value = "加工门户列表")
    @GetMapping("/memberProcessList")
    public Wrapper<PageData<MemberProcessListVO>> memberProcessList(@Valid MemberProcessQO qo) {
        return memberProcessWebService.memberProcessList(qo);
    }

    @ApiOperation(value = "加工门户主页")
    @GetMapping("/memberProcessMain")
    public Wrapper<MemberProcessMainVO> memberProcessMain(@Valid IdDTO dto) {
        return memberProcessWebService.memberProcessMain(dto, isLogin() ? getSysUser() : null);
    }

    @ApiOperation(value = "根据加工门户ID集合获取加工门户")
    @GetMapping("/findByIdIn")
    public Wrapper<List<MemberProcess>> findByIdIn(@Valid IdListDTO dto) {
        return memberProcessWebService.findByIdIn(dto);
    }

    @ApiOperation(value = "收藏/取消收藏")
    @PostMapping(value = "/collect")
    public Wrapper<Void> collect(@RequestBody @Validated CollectDTO dto) {
        return memberProcessWebService.collect(dto, getSysUser());
    }

    @ApiOperation(value = "收藏列表")
    @GetMapping(value = "/collectList")
    public Wrapper<PageData<MemberProcess>> collectList(PageVO dto) {
        return memberProcessWebService.collectList(dto, getSysUser());
    }
}
